#include "Engine/Hdr.h"

#include "Engine/ObjComp.h"

#include "Game.h"

Game game;
/*
struct Serializer
{
	enum
	{
		Serializing,
		Deserializing,
		FixingPointers,
	} State;

	enum Flags
	{
		FL_SER_NONE = 0,
		FL_DESER_NONE = 0,
		FL_FIXUP_NONE = 0,
		FL_OWNER = 1,
		FL_CREATE_IF_NULL = 2,
	};

	template <typename T>
	void operator () (T& value, int flags = 0)
	{
		switch (State)
		{
		case Serializing:
			Serialize(value, flags);
			break;

		case Deserializing:
			Deserialize(value, flags);
			break;

		case FixingPointers:
			FixPointer(value);
			break;
		}
	}

protected:

	void Serialize(bool& val, int flags)
	{
		WriteInt8(&val, flags);
	}

	void Serialize(int& val, int flags)
	{
		WriteInt32(&val, flags);
	}

	void Deserialize(bool& val, int flags)
	{
		ReadInt8(&val, flags);
	}

	void Deserialize(int& val, int flags)
	{
		ReadInt32(&val, flags);
	}

	template <typename T>
	void Serialize(T& val, int flags)
	{
		val.Serialize(*this, flags);
	}

	template <typename T>
	void Serialize(T* val, int flags)
	{
		if (flags & FL_OWNER)
		{
			intptr_t id = (intptr_t)val;
			Serialize(id, flags);
			Serialize(*val, flags^FL_OWNER);
		}
		else
		{
			mPointers[(intptr_t)val] = val;
			intptr_t id = (intptr_t)val;
			Serialize(id, flags);
		}
	}

	template <typename T>
	void Deserialize(T& val, int flags)
	{
		val.Deserialize(*this, flags);
	}

	template <typename T>
	void Deserialize(T* val, int flags)
	{
		if (flags & FL_OWNER)
		{
			if (!val && (flags & FL_CREATE_IF_NULL))
				val = new T();

			intptr_t id = 0;
			Deserialize(id, flags);
			mPointers[id] = val;
			Deserialize(*val, flags^FL_OWNER);
		}
		else
		{
			/// Nothing yet
		}
	}

	virtual void WriteInt8(int8_t* val, int flags) = 0;
	virtual void WriteInt32(int8_t* val, int flags) = 0;

	virtual void ReadInt8(int8_t* val, int flags) = 0;
	virtual void ReadInt32(int8_t* val, int flags) = 0;

	template <typename T>
	void FixPointer(T& value) { }
	template <typename T>
	void FixPointer(T*& value)
	{
		intptr_t ptr_id = (intptr_t)value;
		value = mPointers[ptr_id];
	}

	/// Fields

	eastl::map<intptr_t, void*> mPointers;
};
*/

//wilsoooon

void Config()
{
	ScreenSize = Vec(SCREEN_WIDTH, SCREEN_HEIGHT);
	ScreenScale = 1.0f;
}

void Init()
{
  game.InitGraphics();
	game.InitGameplay();
}

void Update(float dt)
{
	DoParticles(dt);

	game.Update(dt);
}

void Draw()
{
	ClearScr(Color::Black());

	game.Render();
	game.RenderGUI();

	DrawParticles();
}

bool Quit()
{
	return true;
}